package com.yckj.lawyermanager.dongao.controller;

import com.yckj.lawyermanager.dongao.entity.Lawyer;
import com.yckj.lawyermanager.dongao.service.LawyerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * controller层
 * @author lihang
 */
@Controller
public class LawyerController {
    @Autowired
    LawyerService lawyerService;
    @RequestMapping("/show")
    public String showLawyer(Model model){
        List<Lawyer>lawyerList=lawyerService.findLawyer();
        model.addAttribute("lawList",lawyerList);
        return "../static/displaylawyer.html";
    }
    @RequestMapping("/addLawyer")
    public String addLawyer (Lawyer lawyer){
           lawyerService.addLawyer(lawyer);
           //success代表网页
           return "../static/success.html";


    }
    @RequestMapping("/del")
    public String delLawyer (int lawyerid){
        lawyerService.removeLawyer(lawyerid);
        //success代表网页
        return "../static/success.html";


    }
}
